Welcome  >  Getting Started  >  Language Changes

Getting Started with the Delphi for Microsoftâ .NET Preview Compiler

Directory Layout

After installation, the directory layout will be:

 

                Delphi for .NET Preview

                \bin

                \aspx

                                \bin

                                \framework

                                \units

                \doc

                \units

                \source

                                \rtl

 

Delphi Units and CLR Assemblies

The \units directory contains a number of files, with the extension .dcuil, and dcua. A .dcuil file contains a compiled Delphi unit. The compiler produces a .dcuil output file for every unit except the main unit (e.g. a Program, or Package unit). A .dcuil file can also contain an imported CLR namespace, which might contain classes from multiple assemblies. The .dcua file describes the assemblies that contributed to a namespace.

 

Caching the .dcuil files for CLR namespaces speeds up compilation. The .dcua files are required for the compiler to determine when .dcuil file needs to be recompiled. A .dcuil file must be recompiled when one of its assemblies has changed.

 

Note: The .dcuil and .dcua files are not .NET assemblies themselves. They cannot be examined with tools such as ildasm.

Creating a Simple Application

Begin by creating a directory for the Delphi source code files. Create a file called HelloWorld.dpr, in that directory with the following source code:

 

Program HelloWorld;

 

{$APPTYPE CONSOLE}

 

begin

      Writeln('Hello Delphi!');

end.

 

Now, at the command line, compile the program by executing the command

 

      dccil -V Helloworld.dpr

 

The -V switch includes debugging information in the resulting executable assembly. You can debug this little program with the graphical debugger included with Microsoft's .NET Framework SDK:

 

  1. Run the graphical debugger (DbgCLR), and set HelloWorld.exe as the program to debug (Debug | Program to debug).
  2. Set a breakpoint on the Writeln statement, and begin debugging.
  3. Execution will stop on the breakpoint. Open the Output window, and you will see the message "Hello Delphi!" printed when the Writeln statement is executed.

 

The Delphi for .NET preview compiler produces a managed executable, so you can use any of the .NET Framework SDK tools to examine the compiler's output.

 

Note: Depending on your local configuration, you might have to execute the batch file, corvars.bat, prior to working with .NET Framework SDK tools. This file is located in the bin directory of your .NET Framework SDK installation, and can be executed directly from a command prompt.

 

We can make the program a little more interesting, by using the .NET Framework Class Library directly from Delphi. Change the program above, so that it reads as follows:

 

Program HelloWorld;

 

      // Import the CLR namespace.

      uses System.Windows.Forms;

 

begin

      MessageBox.Show('Hello Delphi!', 'Important Message from Borland');

end.

 

Command-line Options

Typing dccil at the command-line will produce a full list of compiler options. Be aware that not all of these are operational, and some are not applicable. Some options that are applicable are:

 

·         -CC: Generate a console application. This switch is Equivalent to the {$APPTYPE CONSOLE} directive.

·         -CG: Create GUI application (the default)

 

There is a configuration file located with the dccil compiler in the \bin directory. The file, dccil.cfg contains one switch, which sets the unit directory to \units.

 

 


Top  |  Contents  |  Copyrights  |  Borland Developer Network  |  Borland Home